package com.yqg.protection.utils;

import com.yqg.protection.service.IOrganizationService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * projectName:xf-service1
 * author:zxf
 * time:2024/7/27 10:02
 * description:
 */
@Component
@Slf4j
public class OrganUtils {

    @Autowired
    IOrganizationService organizationService;

//    public LambdaQueryWrapper<Client> getClientQueryWrapper(Integer level, Long organizationId) {
//        LambdaQueryWrapper<Client> clientQueryWrapper = new LambdaQueryWrapper<>();
//        clientQueryWrapper.eq(Client::getIsDelete, "0");
//        if (organizationId != null) {
//            if (level == 0) {
//                clientQueryWrapper.eq(Client::getScTeam, organizationId);
//            }
//            if (level == 1) {
//                clientQueryWrapper.eq(Client::getFcTeam, organizationId);
//            }
//            if (level == 2) {
//                clientQueryWrapper.eq(Client::getFbTeam, organizationId);
//            }
//            if (level == 3) {
//                clientQueryWrapper.eq(Client::getCommunity, organizationId);
//            }
//            if (level == 4) {
//                clientQueryWrapper.eq(Client::getBuilding, organizationId);
//            }
//            if (level == 5) {
//                clientQueryWrapper.eq(Client::getUnit, organizationId);
//            }
//            if (level == 6) {
//                clientQueryWrapper.eq(Client::getFloor, organizationId);
//            }
//            if (level == 7) {
//                clientQueryWrapper.eq(Client::getRoom, organizationId);
//            }
//        }
//        return clientQueryWrapper;
//    }
//
//    public HashSet<Long> getIdSet(Integer level, Long organizationId, List<Client> clientList) {
//        HashSet<Long> idSet = new HashSet<>();
//        if (clientList != null && clientList.size() > 0) {
//            for (Client client : clientList) {
//                if (level == 0) {
//                    idSet.add(client.getScTeam());
//                    idSet.add(client.getFcTeam());
//                    idSet.add(client.getFbTeam());
//                    idSet.add(client.getCommunity());
//                    idSet.add(client.getBuilding());
//                    idSet.add(client.getUnit());
//                    idSet.add(client.getFloor());
//                    idSet.add(client.getRoom());
//                }
//                if (level == 1) {
//                    idSet.add(client.getFcTeam());
//                    idSet.add(client.getFbTeam());
//                    idSet.add(client.getCommunity());
//                    idSet.add(client.getBuilding());
//                    idSet.add(client.getUnit());
//                    idSet.add(client.getFloor());
//                    idSet.add(client.getRoom());
//                }
//                if (level == 2) {
//                    idSet.add(client.getFbTeam());
//                    idSet.add(client.getCommunity());
//                    idSet.add(client.getBuilding());
//                    idSet.add(client.getUnit());
//                    idSet.add(client.getFloor());
//                    idSet.add(client.getRoom());
//                }
//                if (level == 3) {
//                    idSet.add(client.getCommunity());
//                    idSet.add(client.getBuilding());
//                    idSet.add(client.getUnit());
//                    idSet.add(client.getFloor());
//                    idSet.add(client.getRoom());
//                }
//                if (level == 4) {
//                    idSet.add(client.getBuilding());
//                    idSet.add(client.getUnit());
//                    idSet.add(client.getFloor());
//                    idSet.add(client.getRoom());
//                }
//                if (level == 5) {
//                    idSet.add(client.getUnit());
//                    idSet.add(client.getFloor());
//                    idSet.add(client.getRoom());
//                }
//                if (level == 6) {
//                    idSet.add(client.getFloor());
//                    idSet.add(client.getRoom());
//                }
//                if (level == 7) {
//                    idSet.add(client.getRoom());
//                }
//            }
//            idSet.remove(null);
//        } else {
//            if (organizationId != null) {
//                idSet.add(organizationId);
//            } else {
//                idSet.addAll((organizationService.list().stream().map(Organization::getId).collect(Collectors.toSet())));
//            }
//        }
//        return idSet;
//    }
}
